#!/bin/sh

#if [ $# -ne 1 ]; then
#  echo usage: sh gf_strip_results.sh implementation-name
#  exit 1
#fi

`make clean`

enum=1;
while [ $enum -le 5 ]; do

if [ $enum -eq 1 ]; then
  name=jerasure;
fi
if [ $enum -eq 2 ]; then
  name=jerasure2;
fi
if [ $enum -eq 3 ]; then
  name=nostatic;
fi
if [ $enum -eq 4 ]; then
  name=split_hier;
fi
if [ $enum -eq 5 ]; then
  name=static;
fi

`rm $name/*.c $name/*.h $name/*.cpp $name/*.o $name/gf_mult $name/gf_basic_tester`

`rm strip-$name`

dir=$name/table_results;
`echo "" >> strip-$name`
`echo $name >> strip-$name`
`cat $dir/avg_mult | tail -n 9 >> strip-$name`
`echo "" >> strip-$name`
`echo "" >> strip-$name`
`echo $name >> strip-$name`
`cat $dir/avg_div | tail -n 9 >> strip-$name`

dir=$name/log_results;
`echo "" >> strip-$name`
`echo "" >> strip-$name`
`echo "" >> strip-$name`
`echo $name >> strip-$name`
`cat $dir/avg_mult | tail -n 19 >> strip-$name`
`echo "" >> strip-$name`
`echo "" >> strip-$name`
`echo $name >> strip-$name`
`cat $dir/avg_div | tail -n 19 >> strip-$name`

dir=$name/shift_results;
`echo "" >> strip-$name`
`echo "" >> strip-$name`
`echo "" >> strip-$name`
`echo $name >> strip-$name`
`cat $dir/avg_mult | tail -n 13 >> strip-$name`
`echo "" >> strip-$name`
`echo "" >> strip-$name`
`echo $name >> strip-$name`
`cat $dir/avg_div | tail -n 13 >> strip-$name`

dir=$name/splitw8_results;
`echo "" >> strip-$name`
`echo "" >> strip-$name`
`echo $name >> strip-$name`
`cat $dir/avg_mult | tail -n 1 >> strip-$name`
`cat $dir/avg_div | tail -n 1 >> strip-$name`

dir=$name/region_results;
`echo "" >> strip-$name`
`echo "" >> strip-$name`
`echo "" >> strip-$name`
`echo $name >> strip-$name`
`cat $dir/results_w08 | tail -n 3 >> strip-$name`
`echo "" >> strip-$name`
`cat $dir/results_w16 | tail -n 3 >> strip-$name`
`echo "" >> strip-$name`
`cat $dir/results_w32 | tail -n 3 >> strip-$name`

enum=`echo $enum | awk '{printf $1 + 1}'`
done
